package demo7;

/**
 * Created by Administrator on 2017/4/5.
 */
//: Months2.java
// A more robust enumeration system
public final class Months2 {
    private String name;
    private Months2(String nm) { name = nm; }
    public String toString() { return name; }
    public final static Months2
            JAN = new Months2("January"),
            FEB = new Months2("February"),
            MAR = new Months2("March"),
            APR = new Months2("April"),
            MAY = new Months2("May"),
            JUN = new Months2("June"),
            JUL = new Months2("July"),
            AUG = new Months2("August"),
            SEP = new Months2("September"),
            OCT = new Months2("October"),
            NOV = new Months2("November"),
            DEC = new Months2("December");
    public final static Months2[] month =  {
            JAN, JAN, FEB, MAR, APR, MAY, JUN,
            JUL, AUG, SEP, OCT, NOV, DEC
    };
    public static void main(String[] args) {
        Months2 m = Months2.JAN;
        System.out.println(m);
        m = Months2.month[12];
        System.out.println(m);
        System.out.println(m == Months2.DEC);
        System.out.println(m.equals(Months2.DEC));
    }
} ///:~
